package Stream;

import java.util.*;

import java.util.stream.Collectors;

public class Demo3 {
    public static void main(String[] args) {
        List<String> list=new ArrayList<>();
        list.add("陌刀");
        list.add("横刀");
        list.add("双刀");
        list.add("伞");
        list.add("扇");
        //收集到set中
        Set<String> set = list.stream().sorted().collect(Collectors.toSet());
        System.out.println(set);
        //收集到map中
        Map<String, String> map = new HashMap<>();
        int i=0;
        map=list.stream().sorted().collect(Collectors.toMap(k->k, v -> "武器"));
        System.out.println(map);
        //收集到数组
        String[] arr = list.toArray(new String[0]);
        System.out.println(Arrays.toString(arr));
    }
}
